package ro.msg.quiz.validator;

import ro.msg.quiz.domain.Quiz;
import ro.msg.quiz.exception.MyException;

//AUTHORS: Elod, Marco

//Class that validates a quiz
public class QuizValidator implements IValidator<Quiz> {

    @Override
    public void validate(Quiz item) throws MyException {
	StringBuilder sb = new StringBuilder();

	if (item.getNrOfQuestions() < 1) {
	    sb.append("The quiz must have at least a question!\n");
	}

	if (sb.length() > 0) {
	    throw new MyException(sb.toString());
	}
    }

}
